package sky.wicket;

import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import sky.domain.City;
import sky.service.CityService;
import sky.wicket.panels.CityPanel;

/**
 * Created with IntelliJ IDEA.
 * User: Gauss
 * Date: 06.10.13
 * Time: 15:21
 * To change this template use File | Settings | File Templates.
 */
public class CityInfo extends BasePage {

    @SpringBean
    CityService cityService;

    public CityInfo() {}

    public CityInfo(PageParameters parameters) {
        addElementsToPage(parameters.get("cityName").toString());
    }

    private void addElementsToPage(String cityName) {
        add(new CityPanel("panel", new Model<City>(cityService.getByName(cityName, false)), false));
    }
}
